@echo off
echo ========================================
echo 测试打卡记录模块API
echo Testing Clock Record API
echo ========================================
echo.

echo [1/5] 测试查询所有打卡记录 GET /api/clock-records
powershell -Command "$response = Invoke-RestMethod -Uri 'http://localhost:8080/api/clock-records' -Method Get; Write-Host '状态码: 200 OK' -ForegroundColor Green; Write-Host '记录数量:' $response.total; if($response.total -gt 0) { $response.data | Select-Object -First 3 | Format-Table -AutoSize }"
echo.

echo [2/5] 测试按员工查询 GET /api/clock-records?empId=1
powershell -Command "try { $response = Invoke-RestMethod -Uri 'http://localhost:8080/api/clock-records?empId=1' -Method Get; Write-Host '状态码: 200 OK' -ForegroundColor Green; Write-Host '员工1的记录数:' $response.total } catch { Write-Host '查询失败' -ForegroundColor Yellow }"
echo.

echo [3/5] 测试新增打卡记录 POST /api/clock-records
powershell -Command "$now = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'; $body = @{ employeeId=1; eventTime=$now; eventType='IN'; source='MANUAL'; remark='测试打卡' } | ConvertTo-Json; try { $response = Invoke-RestMethod -Uri 'http://localhost:8080/api/clock-records' -Method Post -Body $body -ContentType 'application/json'; Write-Host '创建成功!' -ForegroundColor Green; $response.data | Format-List } catch { Write-Host '创建失败' -ForegroundColor Yellow; Write-Host $_.Exception.Message }"
echo.

echo [4/5] 测试按时间范围查询 GET /api/clock-records?from=&to=
powershell -Command "$from = (Get-Date).ToString('yyyy-MM-01'); $to = (Get-Date).ToString('yyyy-MM-dd'); $response = Invoke-RestMethod -Uri ('http://localhost:8080/api/clock-records?from=' + $from + '&to=' + $to) -Method Get; Write-Host '本月记录数:' $response.total -ForegroundColor Cyan"
echo.

echo [5/5] 测试按来源查询 GET /api/clock-records/source/MANUAL
powershell -Command "try { $response = Invoke-RestMethod -Uri 'http://localhost:8080/api/clock-records/source/MANUAL' -Method Get; Write-Host '手工补计记录数:' $response.total -ForegroundColor Cyan } catch { Write-Host '查询失败' -ForegroundColor Yellow }"

echo.
echo ========================================
echo 测试完成！
echo 现在可以访问: http://localhost:8080/clock.html
echo ========================================
pause

